<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>


<title>Sphere Online Judge (SPOJ)  - Problem KZWC</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2" id="metatag">
<meta name="Keywords" content="programming, language, algorithm, spoj, contest, contester, Java, C#, Pascal, C, C++, python, ruby, caml, ocaml, perl, haskell, lisp, prolog, fortran, assembler, asembler, functional, online, judge, problem, problemset, ACM">

<link href="http://www.spoj.pl/gfx/favicon.png" rel="shortcut icon" type="image/x-icon">
<link href="http://www.spoj.pl/rss/" rel="alternate" type="application/rss+xml" title="RSS Feed">
<link href="spoj-04830_archivos/common.css" rel="stylesheet" type="text/css" id="theme">
<link href="spoj-04830_archivos/style.css" rel="stylesheet" type="text/css" id="theme">
<link href="spoj-04830_archivos/tooltips.css" rel="stylesheet" type="text/css" id="theme">
<script type="text/javascript" src="spoj-04830_archivos/jquery_004.js"></script>
<style type="text/css">
<!--
.maintable {width: 755px;} 
-->
</style>
<script type="text/javascript" language="javascript">
<!--
function UnCryptMailto(s) {
	var n=0;
	var r="";
	for(var i=0;i<s.length;i++) {		
		n=s.charCodeAt(i); 
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n+(2));	
	}
	return r;
}
function linkTo_UnCryptMailto(s)	{
	location.href=UnCryptMailto(s);
}
// -->
</script>

</head><body>
<center>
<table class="maintable" id="maintable" cellpadding="10" cellspacing="0">
<tbody><tr>
    <td colspan="2" class="header">
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr>
		<td class="headerleft">
		</td><td class="headercenter">
<h1><img alt="Sphere Online Judge" title="Sphere Online Judge" src="spoj-04830_archivos/sphere-spoj-small.png" style="margin-top: -4px; margin-bottom: -4px;" border="0"></h1>
		</td>
		<td class="headerright">
	</td></tr>
	</tbody></table>
    </td>
</tr>
<tr><td class="menu" valign="top" width="92">


<div class="menucmd"><a href="http://www.spoj.pl/logout"><b style="font-weight: normal;">Log Out</b></a><br><b style="font-weight: normal; margin-right: -100px;">dncampo</b><br><hr><a href="http://www.spoj.pl/myaccount">my account</a><br><a href="http://www.spoj.pl/tutorials">tutorials</a><br><br><a href="http://www.spoj.pl/status">status</a><br><a href="http://www.spoj.pl/submit">submit</a><br><a href="http://www.spoj.pl/problems/classical/sort=0,start=1100">problems</a><br><a href="http://www.spoj.pl/search">search</a><br><br><a href="http://www.spoj.pl/">news</a><br><a href="http://www.spoj.pl/contests">contests</a><br><a href="http://www.spoj.pl/ranks/">ranks</a><br><br><a href="http://www.spoj.pl/forum">forum</a><br><a href="http://www.spoj.pl/comments">comments</a><br><a href="http://www.spoj.pl/credits">credits</a><br><hr></div><a href="http://www.spoj.pl/problems/classical/sort=0,start=1100"></a><br>

	<div class="time">
Server time:</div>
<div class="time">
2009-09-23
<br>
<b>22 : 49 : 42</b>
</div>

</td><td style="padding: 0px; width: 100%;" class="content0" valign="top">
        <table cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr>
                <td style="padding: 0px;" colspan="2"><center>
                                
                </center></td>
        </tr>
        <tr>
                <td class="content" style="padding: 10px;" width="99%"><script type="text/javascript" src="spoj-04830_archivos/jquery_002.js"></script>
<script type="text/javascript" src="spoj-04830_archivos/jquery_003.js"></script>
<script type="text/javascript" src="spoj-04830_archivos/jquery.js"></script>


 <!-- wykorzystywane w pcontent.html (by wiele) -->

<table class="problems" width="100%">
<tbody><tr class="navigation">
<td><a href="http://www.spoj.pl/submit/KZWC/">Submit</a></td>
<td><a href="http://www.spoj.pl/status/KZWC,dncampo/">My submissions</a></td>
<td><a href="http://www.spoj.pl/status/KZWC/">All submissions</a></td>
<td><a href="http://www.spoj.pl/ranks/KZWC/">Best solutions</a></td>
<td><a href="http://www.spoj.pl/problems/KZWC.ps">PS</a></td>
<td><a href="http://www.spoj.pl/problems/KZWC.pdf">PDF</a></td>
<td><a href="http://www.spoj.pl/problems/classical/sort=0,start=1100">Back to list</a></td>
</tr>
</tbody></table>

<div class="prob">


<!-- plik z pomoca kontekstowa (cxhelp_*) dziedziczony po pindex.html -->


<script type="text/javascript" src="spoj-04830_archivos/ASCIIMathMLwFallback.js"></script>
<script type="text/javascript" src="spoj-04830_archivos/ASCIIsvgPI.html"></script>
<script type="text/javascript">
<!--
var AScgiloc = 'http://www.imathas.com/imathas/filter/graph/svgimg.php';
var AMTcgiloc = "/files/gif/";
-->
</script>

<table style="margin-top: 10px;" width="100%">
<tbody><tr>
	<td>
		<h2>SPOJ Problem Set (classical)</h2>
		<h1>4830. Z meet</h1>
		<h2>Problem code: KZWC</h2>
	</td>
	</tr>
</tbody></table>

<p align="justify">
</p><p>The Z-meet is an annual alumni meet of the department of
Computer Science at PSG college of technology,where students of
different batches <br>meet.The batch names are named in a alphabetical
order and ending with Z(hence the name Z-meet).That is
Aztecz,Byzandierz,Calitz,Dextroblitz,Espritz,<br>F5erz and
Griffinxeritz.The event is held in a hall and the students are seated
in random order.The event co-ordinators hav a problem.They need to find<br>the strength of attendence of the event by different batches which is calculated as follows:<br><br>1.each
person in the hall shouts out a number which is calculated as (year of
Z-meet - year of pass-out )^2 if he is a alumni or <br>(year of Z-meet - year of entering )^2 if he is still a student.assume the batch of the year in which Z-meet is not passedout.<br>2.the numbers shouted by each person in the hall is added to get the strength of attendence.<br><br>The year of passing &amp; year of entering of the different batches are given:<br>Aztecz &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;2001-2005<br>Byzandiarz&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2002-2006<br>Calitz&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;2003-2007<br>Dextroblitz&nbsp;&nbsp; &nbsp;2004-2008<br>Espritz &nbsp;&nbsp; &nbsp;2005-2009<br>F5erz&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;2006-2010<br>Griffinxeritz&nbsp;&nbsp; &nbsp;2007-2011 <br><br>for example if the event is held in 2008 the Aztecz batch member shouts (2008-2005)^2=9<br>and a Dextroblitz member shouts (2008-2004)^2=16<br><br>help the event co-ordinator by writing a program to find strength of attendence.</p>
<h3>Input</h3>
<p>ther is a single positive integer T on the first line indicating the number of test cases to follow.<br>then there are T lines each containing a year in which Z-meet is held and a string giving the <br>seating arrangement of the alumni and students.that is A refers to Aztecz member C refers to Calitz member<br>and so on.</p>
<p>&nbsp;</p>
<h3>Output</h3>
<p>For every string,output a single line containing the strength of attendence of the event.</p>
<h3>Example</h3>
<pre><strong>Input:</strong><br>3<br>2008 ADECBA<br>2006 BABACAD<br>2009 BEGFADEG<br><br><strong>Output:</strong><br>48<br>48<br>75<br></pre>

<hr>
<table style="margin-bottom: 10px;" class="probleminfo" align="left" border="0" cellpadding="0" cellspacing="0">
<tbody><tr><td>Added by:</td><td><a href="http://www.spoj.pl/users/balaji_n">balaji</a></td></tr>
<tr><td>Date:</td><td>2009-09-19</td></tr>
<tr><td>Time limit:</td><td>4s
</td></tr>
<tr><td>Source limit:</td><td>50000B</td></tr>
<tr><td>Languages:</td><td>All except: SCALA JS </td></tr>
<tr><td>Resource:</td><td>kruzade 09 practice</td></tr>
	
</tbody></table>
<div id="ccontent">

<hr style="clear: both;">
<a href="#" onclick="toggleComments(); return false;"><span id="comments_sh">hide</span> comments</a><br>

<a id="comments"></a>
<table id="comments_table" width="100%">
		<tbody><tr>
		<td colspan="2">
				</td>
	</tr>
	
	<script language="JavaScript">
	<!--
	$(document).ready(function(){
        $('.pager_link').bind('click', function(me){
                var href=$(me.currentTarget).attr('href');
		$('#ccontent').animate({opacity: 0.5},1);
                $.ajax({
                        type: "GET",
                        url: href+",ajax=1",
                        contentType: "application/x-www-form-urlencoded;charset=ISO-8859-2",
                        success: function(data){
                                $('#ccontent').html(data);
				$('#ccontent').animate({opacity: 1.0},1);
                        },
                        error: function(err){
                                alert('error');
                        }
                });
                return false;
        });
	});
	-->
	</script>
	

			
	<tr>
		<td colspan="2" class="comm comm_odd">
		<font>
		2009-09-21 11:55:06 <b><a href="http://www.spoj.pl/users/prodigyaj">Ajay Nair</a></b> 
		</font>
								<br>
				I thoroughly agree "Reading the problem is harder than actually coding it"
						</td>
	</tr>
				
	<tr>
		<td colspan="2" class="comm comm_even">
		<font>
		2009-09-20 22:36:31 <b><a href="http://www.spoj.pl/users/bleung91">Analysis Mode (Bogardan Hellkite)</a></b> 
		</font>
								<br>
				what the heck?  A guy with 0.2 points and 5 solved questions can become a problem setter?
						</td>
	</tr>
				
	<tr>
		<td colspan="2" class="comm comm_odd">
		<font>
		2009-09-20 20:58:36 <b><a href="http://www.spoj.pl/users/njames">Nicholas James</a></b> 
		</font>
								<br>
				yes please fix the formatting of the test data.
<br>when i used scanf() and getchar() to read the input i was getting
WA. but when I changed to cin (which isn't effected by extra spaces and
new line) i got AC. </td>
	</tr>
				
	<tr>
		<td colspan="2" class="comm comm_even">
		<font>
		2009-09-20 16:06:17 <b><a href="http://www.spoj.pl/users/decowboy">Jelle van den Hooff</a></b> 
		</font>
								<br>
Please, format your problem correctly. There are missing spaces, extra
line breaks and missing capitals. Reading the problem is harder than
actually coding it. </td>
	</tr>
			
</tbody></table>


<script language="javascript" type="text/javascript">
<!--
function getCookieVal (offset) {
        var endstr = document.cookie.indexOf (";", offset);
        if (endstr == -1) { 
                endstr = document.cookie.length; 
        }
        return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg) {
      return getCookieVal (j);
      }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
    }
  return null;
}

function toggleComments() {
        var a = document.getElementById('comments_table');
        var d = a.style.display;
        if( d == "" || d == "block" ){
                d = "none";
                document.getElementById('comments_sh').innerHTML = 'show';
        } else {
                d = "block";
                document.getElementById('comments_sh').innerHTML = 'hide';
        }
        a.style.display = d;
        document.cookie="comments_table="+d+"; path=/;";
}

if( GetCookie('comments_table') == 'none' ){
        document.getElementById('comments_sh').innerHTML = 'show';
        document.getElementById('comments_table').style.display = 'hide';
}

-->
</script>


</div>
<table width="100%">
                <tbody><tr>
                <td colspan="2" height="20"></td>
        </tr>
        <form method="post" action="/comment/KZWC/add/"></form>
        <tr> <td style="padding-left: 5px;" colspan="2">Leave a Comment</td> </tr>
        <tr>
                <td valign="top"></td>
                <td><textarea name="content" cols="40" rows="3"></textarea></td>
        </tr>
                <tr>
                <td colspan="2" style="padding-left: 5px;">
                        <input value="Publish" type="submit">
                        <input name="pcode" value="KZWC" type="hidden">
                </td>
        </tr>
<tr>
<td colspan="2" class="smallgrey" style="padding-left: 5px;">
Notes:
<br>1. Don't post any source code here.
<br>2. Please be careful, leave short comments only. Don't spam here.
<br>3. For more discussion (hints, ideas, solutions) please visit our <a href="http://www.spoj.pl/forum">forum</a>.
<br>4. Authors of the problems are allowed to delete the post and use html code here (e.g. to provide some useful links).
</td>
</tr>
        
        </tbody></table>

</div>
        </td>
</tr><tr>
        <td style="padding: 0px;" colspan="2"><center>
                
</center></td>
</tr>
</tbody></table>
</td>
</tr>

<tr>
<td colspan="2" class="footer">

<script language="javascript" type="text/javascript">
<!--
function swapSheet(sheet, caller) {
    document.getElementById('theme').href=sheet;
    document.cookie="css_0="+sheet+"; path=/;";
    caller.href="#bottom";
}

function setWidth(w, caller) {
    document.getElementById('maintable').style.width=w;
    document.cookie="res="+w+"; path=/;";
    caller.href="#bottom";
}
//-->

</script>
        <table width="100%">
    <tbody><tr>
	<td class="cfooter" align="left" width="10%">
	<a href="http://www.spoj.pl/info/">About SPOJ</a>
	</td>
	<td class="cfooter" align="center">
	    page size:
	    <a href="http://www.spoj.pl/?rsl=755px" onclick="setWidth('755px', this)">800x600</a>
	    <a href="http://www.spoj.pl/?rsl=980px" onclick="setWidth('980px', this)">1024x768</a>
	    <a href="http://www.spoj.pl/?rsl=100%" onclick="setWidth('100%', this)">Full</a>
	    &nbsp;&nbsp;
	    theme:
	    <a href="http://www.spoj.pl/?css=/themes/skin1.css" onclick="swapSheet('/themes/skin1.css', this)">olive</a>
	    <a href="http://www.spoj.pl/?css=/themes/skin2.css" onclick="swapSheet('/themes/skin2.css', this)">banana</a>
	    <a href="http://www.spoj.pl/?css=/themes/skin3.css" onclick="swapSheet('/themes/skin3.css', this)">plum</a>
	</td>
		<td class="cfooter" align="center">
		 <span title="The discussion channel of the Sphere Online Judge community.">
		 <a href="irc://irc.freenode.net/spoj"><b>#spoj</b> at freenode</a>
		 </span>
	</td>
		<td class="cfooter" style="text-align: right;" width="10%">
		<a href="http://www.spoj.pl/rss/"><img src="spoj-04830_archivos/rss10x10.gif" border="0">&nbsp;RSS</a>&nbsp;
	
	</td>
    </tr>
    </tbody></table>
    </td></tr></tbody></table>
</center>
<div style="font-size: 10px; margin-top: 4px; color: rgb(85, 80, 95);"><center>
<a href="http://www.spoj.pl/" style="color: black;">SPOJ</a>
System &#169; 2008-2009
<a href="http://sphere-research.com/" style="color: black;">Sphere Research Labs</a>. 
All Rights Reserved.</center></div>


<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><script src="spoj-04830_archivos/ga.js" type="text/javascript"></script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-10507872-1");
pageTracker._trackPageview();
} catch(err) {}</script>


<div id="hidden" style="visibility: hidden;"></div></body></html>